using System;

namespace UltraLight.MVVM
{
    /// <summary>
    ///     An entry in the event table to keep track of references
    /// </summary>
    public class EventEntry
    {
        private Guid _guid = Guid.NewGuid();

        public bool ExecuteOnDispatcher { get; set; }
        public WeakReference Subscriber { get; set; }

        public static EventEntry Create(bool executeOnDispatcher, WeakReference subscriber)
        {
            return new EventEntry {ExecuteOnDispatcher = executeOnDispatcher, Subscriber = subscriber};
        }

        public override bool Equals(object obj)
        {
            //       
            // See the full list of guidelines at
            //   http://go.microsoft.com/fwlink/?LinkID=85237  
            // and also the guidance for operator== at
            //   http://go.microsoft.com/fwlink/?LinkId=85238
            //

            if (obj == null || GetType() != obj.GetType())
            {
                return false;
            }

            return ((EventEntry) obj)._guid.Equals(_guid);
        }

        public override int GetHashCode()
        {
            return _guid.GetHashCode();
        }

    }
}